﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace UI
{
    public class TableCreator
    {
        static public TableRow CreateRowWithCellAndButton(string btnName, string style)
        {
            TableRow row = new TableRow();
            row.Controls.Add(CreateCellWithButton(btnName, style));
            return row;
        }

        // only for login page...
        static public TableCell CreateCellWithButton(string btnName, string style)
        {
            TableCell cell = new TableCell();
            Button btn = new Button();
            cell.CssClass = style;
            btn.Text = btnName; 
            cell.Controls.Add(btn);

            return cell;
        }

        internal static TableRow CreateRowWithButtons(string fBtnName, string sBtnName, string style)
        {
            TableRow row = new TableRow();
            row.Controls.Add(CreateCellWithButton(fBtnName, style));
            row.Controls.Add(CreateCellWithButton(sBtnName, style));
            return row;
        }

        internal static TableRow CreateRowWithCell(string cellTxt, string style)
        {
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            cell.CssClass = style;
            cell.Text = cellTxt;
            row.Controls.Add(cell);
            return row;            
        }

        internal static TableRow CreateRowWithTextBox(string cellTxt, TextBox txtBox, string style)
        {
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            cell.CssClass = style;
            cell.Text = cellTxt;
            row.Controls.Add(cell); 

            cell = new TableCell();
            txtBox = new TextBox();
            cell.CssClass = style;
            cell.Controls.Add(txtBox);
            row.Controls.Add(cell);
            return row;
        }

        internal static TableRow CreateRowWithDDList(DropDownList ddList, string style)
        {
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            cell.CssClass = style;
            cell.Controls.Add(ddList);
            row.Controls.Add(cell);
            return row;
        }

        static public TableRow RowWithLabelAndTextBox(string info)
        {
            TableRow row = new TableRow();
            row.Controls.Add(CreateCellWithLabel(info));
            row.Controls.Add(CreateCellWithTextBox());
            return row;
        }

        static private TableCell CreateCellWithLabel(string info)
        {
            TableCell cell = new TableCell();
            Label lbl = new Label();
            lbl.Text = info + ": ";
            cell.Controls.Add(lbl);
            return cell;
        }

        static private TableCell CreateCellWithTextBox()
        {
            TableCell cell = new TableCell();
            TextBox txtBox = new TextBox();
            cell.Controls.Add(txtBox);
            return cell;
        }
    }
}